// 这个文件是用来二次封装axios
import axios from 'axios'
import 'nprogress/nprogress.css'
import NProgress from 'nprogress'
const ajax = axios.create({
 baseURL:'http://39.98.123.211/',
 timeout:5000,
})
ajax.interceptors.request.use((config)=>{
  NProgress.start()
  return config})
ajax.interceptors.response.use((response)=>{
  NProgress.done()
  return response.data},
  (error)=>{
    NProgress.done()
    return Promise.reject(new Error(error.message))})
// response打印的是：{config: {transitional: {…}, 
// transformRequest: Array(1), 
// transformResponse: Array(1), timeout: 5000, adapter: ƒ, …}
// data: {code: 200, message: '成功', data: Array(17), ok: true}
// headers: {content-type: 'application/json'}
// request: XMLHttpRequest 
// {onreadystatechange: null, readyState: 4, timeout: 5000, withCredentials: false, upload: XMLHttpRequestUpload, …}
// status: 200
// statusText: "OK"
// [[Prototype]]: Object}
export default ajax